import { Property } from '../../../components/Property'

## Prompt

`Prompt` is a custom single-line [`TextInput`](/docs/components/text-input) component that includes a `prefix` and an `on_submit` callback.

![](/gifs/prompt-1.gif)

### Usage Example

```lua
n.prompt({
  prefix = " > ",
  placeholder = "Enter a command",
  border_label = {
    text = "Command",
    align = "center",
  },
  on_submit = function(value)
    print(value)
  end,
})
```

### Properties

#### value

<Property
  types={["string"]}
/>

#### prefix

<Property
  types={["string"]}
/>

#### placeholder

> Optional placeholder text to show when the input is empty.
> Can be a string, a single virtual text chunk, or a list of virtual text chunks.

<Property
  defaultValue='nil'
  types={['string', '{ [1]: string, [2]: string }[]', 'nil']}
/>

A virtual text chunk is a tuple-like table where the first element
is the text and the second element is the highlight group.

```lua
local placeholder = {
  { "Hello", "Comment" },
  { "World", "String" },
}
```

#### on_change

<Property
  types={['fun(value: string, component: Prompt): nil']}
/>

#### on_submit

<Property
  types={['fun(value: string, component: Prompt): nil']}
/>

#### submit_key

<Property
  defaultValue="<CR>"
  types={["string[]", "string"]}
/>

### Hightlight Groups

- `NuiComponentsPromptPrefix`

